package j02stringb;

public class J1 {
    public static void main(String[] args) {
        StringBuilder sb1 = new StringBuilder();
        //自动扩容
        StringBuilder sb2 = new StringBuilder(20);
        StringBuilder sb3 = new StringBuilder("abc");

        System.out.println("sb3 = " + sb3);
        System.out.println("sb3.length() = " + sb3.length());//3
        System.out.println("sb3.capacity() = " + sb3.capacity());//19没啥意义

        System.out.println("sb3.charAt(2) = " + sb3.charAt(2));
//        System.out.println("sb3.charAt(200) = " + sb3.charAt(200));
//        System.out.println("abc".charAt(1000));
        sb3.append("xyz");
        System.out.println("sb3 = " + sb3);
        System.out.println("=====");
        StringBuilder sb200 = new StringBuilder("abc");
        sb200.insert(1,"#深奥");
        System.out.println("sb200 = " + sb200);

        System.out.println("===");
        StringBuilder sb300 = new StringBuilder("xytqwer");
        sb300.delete(1,3);//xqwer
        System.out.println("sb300 = " + sb300);

        int age = 8;
        System.out.println("age = " + age);

        System.out.println("====");
        StringBuilder s400 = new StringBuilder("asdfgh");
//        s400.replace(1,3,"xx");
//        System.out.println("s400 = " + s400);
//        s400.setCharAt(0,'_');
//        s400.reverse();
        System.out.println("s400 = " + s400);

        String ss400 = s400.toString();
        System.out.println("ss400 = " + ss400);


    }
}


class J2{
    public static void main(String[] args) {
        StringBuffer sb1 = new StringBuffer("abc");
        sb1.reverse();
        System.out.println("sb1 = " + sb1);
    }
}